package com.liu.frame.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.liu.frame.R;
import com.liu.frame.base.BaseActivity;
import com.liu.frame.utils.LogUtils;
import com.liu.frame.utils.ToastUtils;
import com.uuzuche.lib_zxing.activity.CaptureActivity;
import com.uuzuche.lib_zxing.activity.CodeUtils;

/**
 * Created by 刘智强 on 2017/2/23.
 */

public class TestWebPActivity extends BaseActivity {
    private static final int REQUEST_CODE = 901;
    private ImageView iv_icon;

    @Override
    public void setContentLayout() {
        setContentView(R.layout.activity_testwebp);

    }

    @Override
    public void setTitleView() {

    }

    @Override
    public void initView() {
        iv_icon = $(R.id.iv_icon);

    }

    @Override
    public void initEvents() {
        iv_icon.setOnClickListener(this);

    }

    @Override
    public void objectLogic() {
        iv_icon.setImageResource(R.mipmap.ic_launcher);


    }

    @Override
    public void onClickEvent(View v) {
        switch (v.getId()) {
            case R.id.iv_icon:
                startActivityForResult(new Intent(mActThis, CaptureActivity.class), REQUEST_CODE);
                break;
            default:
        }

    }

    @Override
    public void loadCache() {
        iv_icon.setBackgroundResource(R.mipmap.welcome_three);

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE&&data!=null) {
            Bundle bundle = data.getExtras();
            if (bundle != null) {
                if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) {
                    String result = bundle.getString(CodeUtils.RESULT_STRING);
                    LogUtils.e("result---->" + result);

                } else if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_FAILED) {
                    ToastUtils.myToast(mActThis, "解析失败了");
                }
            }
        }

    }
}
